home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ARASAN_S.ZIP / TIMECTRL.H < prev    next >
C/C++ Source or Header  |  1994-07-19  |  2KB  |  109 lines

  1. // Copyright 1994 by Jon Dart.  All Rights Reserved.
  2.  
  3. #ifndef _Time_Control_H
  4. #define _Time_Control_H
  5.  
  6. #include <time.h>
  7.  
  8. enum Search_Type { Fixed_Ply, Time_Limit, Game, Tournament, None };
  9.     
  10. struct Time_Limits
  11. {
  12.      unsigned moves, minutes;
  13. };
  14.     
  15. union Search_Limit
  16. {
  17.     unsigned max_ply;   // for Fixed_Ply search
  18.     unsigned long seconds;  // for Time_Limit searches
  19.     Time_Limits limit;  // for Tournament and Game searches
  20. };
  21.  
  22. enum Control { First, Second };
  23.  
  24. class Time_Control
  25. {
  26. public:    
  27.  
  28.     Time_Control();
  29.     
  30.     Time_Control(Search_Type, Search_Limit);
  31.  
  32.     Search_Limit get_search_limit() const
  33.     {
  34.     return limits;
  35.     }
  36.     
  37.     void set_search_limit( Search_Limit lim )
  38.     {
  39.     limits = lim;
  40.     }
  41.     
  42.     Search_Type get_search_type() const
  43.     {
  44.     return srctype;
  45.     }
  46.     
  47.     void set_search_type( Search_Type typ )
  48.     {
  49.         srctype = typ;
  50.     }
  51.     
  52.     const char *Image() const;
  53.     
  54. private:    
  55.     Search_Limit limits;
  56.     Search_Type srctype;
  57. };
  58.  
  59. class Time_Info : public Time_Control
  60. {
  61. public:
  62.     Time_Info();
  63.     
  64.     Time_Info(Search_Type, Search_Limit);
  65.     
  66.     int get_period() const
  67.     {
  68.         return period;        
  69.     }
  70.     
  71.     void set_period(const int n)
  72.     {
  73.     period = n;
  74.     }
  75.     
  76.     int get_last_time_control() const
  77.     {
  78.     return last_time_control;
  79.     }
  80.     
  81.     void set_last_time_control( const int n )
  82.     {
  83.     last_time_control = n;
  84.     }
  85.     
  86.     void set_time_control( const Time_Control &tc )
  87.     {
  88.     *((Time_Control*)this) = tc;
  89.     }
  90.     
  91.     time_t get_bonus() const
  92.     {
  93.        return bonus;        
  94.     }
  95.     
  96.     void set_bonus( time_t b )
  97.     {
  98.        bonus = b;
  99.     }
  100.  
  101. private:
  102.     int period; // time control period, 0..n
  103.     int last_time_control; // moves made at end of last time control
  104.     time_t bonus; // time left from last time control        
  105. };
  106.  
  107. #endif
  108.  
  109.